Test   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 18
dl 0
loc 35
rs 10
c 0
b 0
f 0

8 Functions

Rating   Name   Duplication   Size   Complexity  
A setTmpFolder 0 3 1
A mockAPI 0 3 1
A startMockApp 0 3 1
A cleanTmpFolder 0 3 1
A unMockAPI 0 3 1
A createAPI 0 3 1
A mockAppUrl 0 5 1
A stopMockApp 0 3 1
1
import fse from 'fs-extra';
2
import API from './entry';
3
import { tmpFolder } from './constants';
4
import { mockAPI, unMockAPI, startMockApp, stopMockApp } from  './mock';
5
6
export * from './utils';
7
export * from './constants';
8
9
export default class Test {
10
    createAPI(url = 'http://mock/', opts = {}) {
11
        return new API(url, opts);
12
    }
13
14
    async setTmpFolder() {
15
        await fse.ensureDir(tmpFolder);
16
    }
17
18
    async cleanTmpFolder() {
19
        await fse.remove(tmpFolder);
20
    }
21
22
    mockAPI() {
23
        mockAPI();
24
    }
25
26
    unMockAPI() {
27
        unMockAPI();
28
    }
29
30
    async startMockApp() {
31
        this._server = await startMockApp();
32
    }
33
34
    get mockAppUrl() {
35
        const { port } = this._server.address();
36
37
        return `http://localhost:${port}`;
38
    }
39
40
    async stopMockApp() {
41
        await stopMockApp(this._server);
42
    }
43
}
44
45